package Validate;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class Myvalidate extends Validator {
    @Override
    protected void validate(Controller controller) {
        setShortCircuit(true);
        validateRequiredString("username","nameMsg","用户名为空");
        validateRequiredString("password","passwordMsg","密码为空");
        validateCaptcha("validate", "msg", "验证码错误");
    }

    @Override
    protected void handleError(Controller controller) {
        controller.keepPara();
        controller.set("msg", controller.getAttr("msg"));
        controller.forwardAction("/login");
    }
}
